﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace YummyGame.Framework
{
    public class SkillAction_lua_script : SkillAction
    {
        private string file;
        private string entry;
        public override ActionRunState Excute()
        {
#if XLUA_SUPPORT
            if(!string.IsNullOrEmpty(file))
                AssetManager.Instance.LoadLuaFile(file, entry);
            return ActionRunState.Success;
#else
            Debug.LogError("当前不支持lua脚本");
            return ActionRunState.Success;
#endif
        }

        public override void Reactive()
        {
            SkillActionPrototype_lua_script lua_script = Prototype as SkillActionPrototype_lua_script;
            file = lua_script.file;
            entry = lua_script.entry;
        }

        public override ActionRunState Run()
        {
            return ActionRunState.Success;
        }

        public override void Dispose()
        {
            Pools.GetSkillRuntime<SkillAction_lua_script>().Recover(this);
        }
    }
}
